<?php

trait runing
{
	private $name;
	public function run()
	{
		echo $this->name .  ' runing....';
	}
}

trait instance
{
	static $instance;
	public static function getInstance(...$args)
	{
		if(!isset(self::$instance)){
			self::$instance = new self(...$args);
		}
		return self::$instance;
	}
}


class person
{
	use instance,runing;
	private function __construct(string $name)
	{
		$this->name = $name;
	}
}

class animal
{
	use instance;
	private $animal;
	private function __construct(string $animal)
	{
		$this->animal = $animal;
	}
	public function eat()
	{
		echo $this->animal . 'eating...';
	}
}

$jmz = person::getInstance('jmz');
$jmz->run();

$dog = animal::getInstance('dog');
$dog->eat();